/*
 * @Author: kaikaima
 * @Date: 2021-02-11 10:41:33
 * @LastEditTime: 2021-02-11 11:51:02
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /undefined/home/messi/Data_Structure_and_Algorithm_GIT/PAT/Basic_level/1012.cpp
 */
#include <iostream>

class Hash{
    private:
    class Node{
        public:
        int key;
        Node* next;
        Node() {next=NULL;};
        Node(int _x) {key=_x; next=NULL;};
    };
    Node* element[5]={NULL};
    int insert(int _x, Node** _space);
    int release(Node* _p);
    public:
    Hash() {};
    ~Hash();
    int input(int _x);
    int output();
};

int Hash::insert(int _x, Node** _space){
    if(*_space==NULL){
        Node* p=new Node(_x);
        *_space=p;
        return 0;
    }
    else{
        return insert(_x,&((*_space)->next));
    }
};

int Hash::release(Node* _p){
    if(_p!=NULL){
        release(_p->next);
    }
    else delete _p;
    return 0;
};

Hash::~Hash(){
    for(int i=0;i<5;i++){
        Node* p=element[i];
        if(p!=NULL) release(p);
    }
};

int Hash::input(int _a){
    return insert(_a,element+(_a%5));
};

int Hash::output(){
    int A[5]={0,0,0,0,0};
    double A4=0.0;
    {
        Node* p=element[0];
        while(p!=NULL){
            if((p->key)%10==0) A[0]+=(p->key);//A1 = 能被5整除的数字中所有偶数的和；
            p=p->next;
        }
    }
    {
        Node* p=element[1];
        int i=1;
        while(p!=NULL){
            A[1]+=i*(p->key);//A2 = 将被5除后余1的数字按给出顺序进行交错求和
            i=-i;
            p=p->next;
        }
    }
    {
        Node* p=element[2];
        while(p!=NULL){
            A[2]++;//A3 = 被5除后余2的数字的个数
            p=p->next;
        }
    }
    {
        Node* p=element[3];
        double num=0.0;
        while(p!=NULL){
            A[3]+=(p->key);
            num+=1.0;
            p=p->next;
        }
        A4=((double) A[3])/num;//A4 = 被5除后余3的数字的平均数，精确到小数点后1位
    }
    {
        Node* p=element[4];
        while(p!=NULL){
            if((p->key)>A[4]) A[4]=(p->key);//A5 = 被5除后余4的数字中最大数字
            p=p->next;
        }
    }
    if(element[0]==NULL) std::cout<<"N";
    else std::cout<<A[0];
    for(int i=1;i<5;i++){
        if(i!=3){
            if(element[i]==NULL) std::cout<<" N";
            else std::cout<<" "<<A[i];
			}
		else{
			if(element[3]==NULL) std::cout<<" N";
    		else std::cout<<" "<<A4;
		}
    }
    std::cout<<std::endl;
    return 0;
}

int main (int argc, char* argv[]){
    Hash hashtable;
    int a; std::cin>>a;
    while (a>=0)
    {
        hashtable.input(a);
        std::cin>>a;
    }
    hashtable.output();
    return 0;
}